import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/autonym/help/autonym_help.dart';
import 'package:honeypotflutter/modules/autonym/views/autonym_item_image.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/views/public_scrollView.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_button.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import 'logic.dart';

class AutonymImagePage extends StatefulWidget {
  const AutonymImagePage({Key? key}) : super(key: key);

  @override
  State<AutonymImagePage> createState() => _AutonymImagePageState();
}

class _AutonymImagePageState extends State<AutonymImagePage> {
  final AutonymImageLogic logic = Get.put(AutonymImageLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(navigationTitle: "实名认证"),
      body: HLScrollView(
        padding: EdgeInsets.all(16),
        children: [
          MGCard(
            children: [
              Container(
                margin: EdgeInsets.only(top: 10),
                width: double.infinity,
                child: Text(
                  "请拍照上传身份证",
                  style: TextStyle(
                    fontSize: MGFont.textFont1,
                    color: MGColors.text1Color,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
              GetBuilder<AutonymImageLogic>(
                  builder: (controller) => AutonymItemImage(
                        title: "1、点击上传身份证人像面",
                        file: controller.frontInfo?.file,
                        hintImage: MGImage.image("autonym_zheng", type: ImagePathType.autonym),
                        type: AutonymSelectImageType.front,
                        onSelectImage: logic.selectImage,
                        onDelete: logic.deleteImage,
                      )),
              GetBuilder<AutonymImageLogic>(
                builder: (controller) => AutonymItemImage(
                  title: "2、点击上传身份证国徽面",
                  file: controller.reverseInfo?.file,
                  hintImage: MGImage.image("autonym_fan", type: ImagePathType.autonym),
                  type: AutonymSelectImageType.reverse,
                  onSelectImage: logic.selectImage,
                  onDelete: logic.deleteImage,
                ),
              ),
              GetBuilder<AutonymImageLogic>(
                  builder: (controller) => AutonymItemImage(
                        title: "3、请手持身份证拍照上传",
                        file: controller.personInfo?.file,
                        hintImage: MGImage.image("autonym_person", type: ImagePathType.autonym),
                        type: AutonymSelectImageType.person,
                        onSelectImage: logic.selectImage,
                        onDelete: logic.deleteImage,
                      ))
            ],
          )
        ],
      ),
      bottomNavigationBar: Obx(() => MGButton(
            title: "下一步",
            enable: logic.enable.value,
            padding: EdgeInsets.only(left: 20, right: 20, bottom: 35, top: 20),
            buttonAction: logic.submitAction,
          )),
    );
  }

  @override
  void dispose() {
    Get.delete<AutonymImageLogic>();
    super.dispose();
  }
}
